

function say() {
    alert("LC:844. 比较含退格的字符串");
}
say();

/**
 * @param {string} S
 * @param {string} T
 * @return {boolean}
 */
var backspaceCompare = function(S, T) {
  //8:17-32
  var sStack = []
  for(var i = 0; i < S.length; i++){
    var item = S.charAt(i)
    if(item == '#'){
      sStack.pop()
    }else {
      sStack.push(item)
    }
  }

  var tStack = []
  for(var i = 0; i < T.length; i++){
    var item = T.charAt(i)
    if(item == '#'){
      tStack.pop()
    }else {
      tStack.push(item)
    }
  }

  if(sStack.length != tStack.length){
    return false
  }else {
    for(var i = 0; i < sStack.length; i++){
      if(sStack[i] != tStack[i]){
        return false
      }
    }
    return true
  }
};
